package it.okkam.utility;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class ApriStream {
	public ArrayList<String> apriStream(String filePath) {
		// definiamo il percorso al file da leggere
		ArrayList<String> listaRecord = null;
		File doc = new File(filePath);
		InputStream is;
		BufferedReader reader;
		String stringaLetta = "";
		try {
			listaRecord = new ArrayList<String>();
			is = new FileInputStream(doc);
			reader = new BufferedReader(new InputStreamReader(is));

			while ((stringaLetta = reader.readLine()) != null) {
				if ((stringaLetta != "null")
						|| !(stringaLetta.contains("Codice"))) {
					stringaLetta = stringaLetta.trim();// tolgo spazi prima e
														// dopo
					listaRecord.add(stringaLetta);

				}
			}

			reader.close();
			is.close();

		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println(e.getMessage());
		}

		return listaRecord;

	}

}
